package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import model.Piece;
import view.GUI;

/**
 * Listens for events that request the name of the Piece to change.
 * @author Hedja
 */
public class NameChangeListener implements ActionListener {

	private Piece piece;
	private GUI gui;

	public NameChangeListener(Piece piece, GUI gui) {
		this.piece = piece;
		this.gui = gui;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		String newName = gui.getMenuPanel().getPieceName();
		piece.setName(newName);			//Change the name of the Piece
		gui.changePieceName(newName);	//Change the name shown in the GUI
	}



}
